package com.itwn.portal.controller;

import com.itwn.portal.model.entity.BookType;
import com.itwn.portal.service.BookTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/bookType")
@Api(tags = "书籍分类")
// @CrossOrigin(origins = "*")  配置了全局跨域这里就不要再配置
public class BookTypeController {

    @Autowired
    private BookTypeService bookTypeService;

    /**
     * 查询书籍分类的API接口
     * @return
     */
    @GetMapping
    @ApiOperation("查询书籍分类")
    public ResponseEntity<List<BookType>> findAll() {
        List<BookType> list = bookTypeService.findAll();
        return ResponseEntity.ok(list);
    }
}
